package com.hnkywl.sts.entity.htgl;

import com.hnkywl.sts.entity.BaseEntity;
import com.hnkywl.sts.entity.base.Fj;
import com.hnkywl.sts.entity.base.Gspz;
import com.hnkywl.sts.entity.base.Sjzdz;
import com.hnkywl.sts.entity.jhgl.Bgjhhz;
import com.hnkywl.sts.entity.jhgl.Cgwzjh;
import com.hnkywl.sts.entity.jhgl.Xy;
import com.hnkywl.sts.entity.organ.*;
import com.hnkywl.sts.entity.sys.Yg;
import org.hibernate.annotations.Cascade;
import org.hibernate.annotations.NotFound;
import org.hibernate.annotations.NotFoundAction;
import org.hibernate.annotations.Where;

import javax.persistence.*;
import java.util.Date;
import java.util.List;

/**
 * 说明：合同
 * 包:        com.hnkywl.sts.entity.htgl
 * 类描述:    合同
 * 修改备注: [说明本次修改内容]
 * 版本:        [v1.0]
 */
@Entity
@Table(name = "T_BIZ_HT")
@Where(clause = "deleted!='1'")
@Inheritance(strategy = InheritanceType.SINGLE_TABLE)
@DiscriminatorColumn(name = "TYPE", discriminatorType = DiscriminatorType.STRING)
@DiscriminatorValue("ht")
public class Ht extends BaseEntity {
    @Id
    @SequenceGenerator(name = "seqHt", allocationSize = 1, sequenceName = "SEQ_BIZ_HT")
    @GeneratedValue(strategy = GenerationType.SEQUENCE, generator = "seqHt")
    private Long id;

    /**
     * 合同编号
     */
    private String htbm;

    @ManyToOne(fetch = FetchType.LAZY)
    @JoinColumn(name = "LJ_ID")
    @NotFound(action = NotFoundAction.IGNORE)
    @Where(clause = "deleted!='1'")
    private Lj lj;

    /**
     * 签订日期
     */
    private Date qdrq;

    /**
     * 签订人
     */
    private String htqdr;

    /**
     * 签订地点
     */
    private String qddd;

    /**
     * 合作方
     */
    @ManyToOne(fetch = FetchType.LAZY)
    @JoinColumn(name = "HZF_ID")
    @NotFound(action = NotFoundAction.IGNORE)
    private Gsjg hzf;

    /**
     * 质押方
     */
    @ManyToOne(fetch = FetchType.LAZY)
    @JoinColumn(name = "ZYF_ID")
    @NotFound(action = NotFoundAction.IGNORE)
    private Zyf zyf;

    /**
     * 仓库
     */
    @ManyToOne(fetch = FetchType.LAZY)
    @JoinColumn(name = "CK_ID")
    @NotFound(action = NotFoundAction.IGNORE)
    private Ck ck;


    /**
     * 优惠比例%
     */
    private Double yhbl = 0.0;

    /**
     * 税率
     */
    private Double sl = 0.0;

    /**
     * 利率
     */
    private Double ll = 0.0;


    //免息天数
    private Integer mxts;

    //贴息率
    private Double txl;

    /**
     * 关联采购物资计划
     */
    @ManyToOne(fetch = FetchType.LAZY, cascade = CascadeType.MERGE)
    @JoinColumn(name = "WZJH_ID")
    @NotFound(action = NotFoundAction.IGNORE)
    private Cgwzjh wzjh;
    /**
     * 关联保供计划汇总
     */
    @ManyToOne(fetch = FetchType.LAZY, cascade = CascadeType.MERGE)
    @JoinColumn(name = "BGJHHZ_ID")
    @NotFound(action = NotFoundAction.IGNORE)
    private Bgjhhz bgjhhz;

    /**
     * 关联协议
     */
    @ManyToOne(fetch = FetchType.LAZY)
    @JoinColumn(name = "XY_ID")
    @NotFound(action = NotFoundAction.IGNORE)
    private Xy xy;

    /**
     * 付款方式
     */
    @ManyToOne(fetch = FetchType.LAZY)
    @JoinColumn(name = "SJZDZ_FKFS_ID")
    private Sjzdz fkfs;

    /**
     * 交货时间
     */
    private Date jhsj;

    /**
     * 交货地点
     */
    private String jhdd;

    /**
     * 交货方式
     */
    private String jhfs;

    @ManyToOne(fetch = FetchType.LAZY)
    @JoinColumn(name = "SBGS_ID")
    @NotFound(action = NotFoundAction.IGNORE)
    private Gsjg sbgs;


    @ManyToOne(fetch = FetchType.LAZY)
    @JoinColumn(name = "SBBM_ID")
    @NotFound(action = NotFoundAction.IGNORE)
    private Nbbm sbbm;

    @ManyToOne(fetch = FetchType.LAZY)
    @JoinColumn(name = "SBR_ID")
    @NotFound(action = NotFoundAction.IGNORE)
    private Yg sbr;

    private Boolean zbcg = false;
    //是否导入保供合同
    private Boolean sfdrbght = false;
    /**
     * 物流方公司
     */
    @ManyToOne(fetch = FetchType.LAZY)
    @JoinColumn(name = "WLFGS_ID")
    @NotFound(action = NotFoundAction.IGNORE)
    private Gsjg wlfgs;

    /**
     * 物流方部门
     */
    @ManyToOne(fetch = FetchType.LAZY)
    @JoinColumn(name = "WLFBM_ID")
    @NotFound(action = NotFoundAction.IGNORE)
    private Nbbm wlfbm;

    /**
     * 物流方人员
     */
    @ManyToOne(fetch = FetchType.LAZY)
    @JoinColumn(name = "WLFRY_ID")
    @NotFound(action = NotFoundAction.IGNORE)
    private Yg wlfry;

    /**
     * 结束日期
     */
    private Date jsrq;

    /**
     * 合同性质
     */
    @ManyToOne(fetch = FetchType.LAZY)
    @JoinColumn(name = "SJZDZ_HTXZ_ID")
    private Sjzdz htxz;

    /**
     * 备注
     */
    private String bz;

    /**
     * 制单人
     */
    @ManyToOne(fetch = FetchType.LAZY)
    @JoinColumn(name = "ZDR_ID")
    @NotFound(action = NotFoundAction.IGNORE)
    private Yg zdr;

    /**
     * 制单时间
     */
    private Date zdsj;

    /**
     * 状态   ysp 已审批  yzz 已终止  yly  已完结
     */
    private String zt;

    /**
     * 合同附件
     */
    @OneToMany(cascade = CascadeType.MERGE, fetch = FetchType.LAZY, targetEntity = Fj.class)
    @JoinColumn(name = "HT_ID")
    private List<Fj> fjList;

    /**
     * 合同明细
     */
    @OneToMany(fetch = FetchType.LAZY, targetEntity = Htmx.class)
    @Cascade({org.hibernate.annotations.CascadeType.SAVE_UPDATE})
    @JoinColumn(name = "HT_ID")
    @Where(clause = "deleted!='1'")
    private List<Htmx> htmxList;

    /**
     * 合同文本
     */
    @OneToOne(fetch = FetchType.LAZY)
    @JoinColumn(name = "HTWB_ID")
    @NotFound(action = NotFoundAction.IGNORE)
    private Htwb htwb;

    /**
     * 公式配置
     */
    @OneToOne(fetch = FetchType.LAZY)
    @JoinColumn(name = "GSPZ_ID")
    @NotFound(action = NotFoundAction.IGNORE)
    private Gspz gspz;


    /**
     * 关联流程实体
     */
    @Basic
    @Column(name = "LC_ID")
    private String processInstanceId;

    //已付金额
    private Double yfje = 0d;

    @OneToMany(fetch = FetchType.LAZY, targetEntity = Fkfs.class)
    @Cascade({org.hibernate.annotations.CascadeType.SAVE_UPDATE})
    @JoinColumn(name = "HT_ID")
    private List<Fkfs> htfkfs;

    //销售合同号
    private String xsxt_htbm;

    /**
     * 是否为最后一次赎货（0 表示不是最后一次赎货 1 表示到了最后一次赎货  2 表示该合同赎货完结）
     */
    private int lastsh = 0;

    // 实际结算价和采购合同价是否相同 0:不相同，1;是相同
    private String jgsfxt;

    /**
     * 合同模式；xsms表示线上模式，xxms表示线下模式
     */
    private String htms;

    /**
     * 订单id
     */
    private String orderId;

    /**
     * "mid":居中结算订单，"normal":普通订单 A20160427zhp
     */
    private String extension;

    //是否后定价,0和空：否，1：是
    private Boolean sfhdj;

    //保证金使用方式 :0:一次性使用  1:按比例使用,2:无保证金
    private Integer bzjfs;

    /**
     * 该订单是否在运营中结算；0和空，是；1：否
     */
    private String sfjs;

    public String getSfjs() {
        return sfjs;
    }

    public void setSfjs(String sfjs) {
        this.sfjs = sfjs;
    }

    public Integer getBzjfs() {
        return bzjfs;
    }

    public void setBzjfs(Integer bzjfs) {
        this.bzjfs = bzjfs;
    }

    public Boolean getSfhdj() {
        return sfhdj;
    }

    public void setSfhdj(Boolean sfhdj) {
        this.sfhdj = sfhdj;
    }

    public Double getYhbl() {
        return yhbl;
    }

    public void setYhbl(Double yhbl) {
        this.yhbl = yhbl;
    }

    public Gspz getGspz() {
        return gspz;
    }

    public void setGspz(Gspz gspz) {
        this.gspz = gspz;
    }

    public String getExtension() {
        return extension;
    }

    public void setExtension(String extension) {
        this.extension = extension;
    }

    public String getOrderId() {
        return orderId;
    }

    public void setOrderId(String orderId) {
        this.orderId = orderId;
    }

    public String getJgsfxt() {
        return jgsfxt;
    }

    public void setJgsfxt(String jgsfxt) {
        this.jgsfxt = jgsfxt;
    }

    public int getLastsh() {
        return lastsh;
    }

    public void setLastsh(int lastsh) {
        this.lastsh = lastsh;
    }

    public String getXsxt_htbm() {
        return xsxt_htbm;
    }

    public void setXsxt_htbm(String xsxt_htbm) {
        this.xsxt_htbm = xsxt_htbm;
    }

    public Ck getCk() {
        return ck;
    }

    public void setCk(Ck ck) {
        this.ck = ck;
    }

    public Integer getMxts() {
        return mxts;
    }

    public void setMxts(Integer mxts) {
        this.mxts = mxts;
    }

    public Double getTxl() {
        return txl;
    }

    public void setTxl(Double txl) {
        this.txl = txl;
    }

    public Double getYfje() {
        return yfje;
    }

    public void setYfje(Double yfje) {
        this.yfje = yfje;
    }

    public Long getId() {
        return id;
    }

    public void setId(Long id) {
        this.id = id;
    }

    public Lj getLj() {
        return lj;
    }

    public void setLj(Lj lj) {
        this.lj = lj;
    }

    public Bgjhhz getBgjhhz() {
        return bgjhhz;
    }

    public void setBgjhhz(Bgjhhz bgjhhz) {
        this.bgjhhz = bgjhhz;
    }

    public Date getQdrq() {
        return qdrq;
    }

    public void setQdrq(Date qdrq) {
        this.qdrq = qdrq;
    }

    public String getQddd() {
        return qddd;
    }

    public void setQddd(String qddd) {
        this.qddd = qddd;
    }

    public Double getSl() {
        return sl;
    }

    public void setSl(Double sl) {
        this.sl = sl;
    }

    public Double getLl() {
        return ll;
    }

    public void setLl(Double ll) {
        this.ll = ll;
    }

    public Cgwzjh getWzjh() {
        return wzjh;
    }

    public void setWzjh(Cgwzjh wzjh) {
        this.wzjh = wzjh;
    }

    public Xy getXy() {
        return xy;
    }

    public void setXy(Xy xy) {
        this.xy = xy;
    }

    public Gsjg getHzf() {
        return hzf;
    }

    public void setHzf(Gsjg hzf) {
        this.hzf = hzf;
    }

    public Zyf getZyf() {
        return zyf;
    }

    public void setZyf(Zyf zyf) {
        this.zyf = zyf;
    }

    public Sjzdz getFkfs() {
        return fkfs;
    }

    public void setFkfs(Sjzdz fkfs) {
        this.fkfs = fkfs;
    }

    public Date getJhsj() {
        return jhsj;
    }

    public void setJhsj(Date jhsj) {
        this.jhsj = jhsj;
    }

    public String getJhdd() {
        return jhdd;
    }

    public void setJhdd(String jhdd) {
        this.jhdd = jhdd;
    }

    public String getJhfs() {
        return jhfs;
    }

    public void setJhfs(String jhfs) {
        this.jhfs = jhfs;
    }

    public Gsjg getSbgs() {
        return sbgs;
    }

    public void setSbgs(Gsjg sbgs) {
        this.sbgs = sbgs;
    }

    public Nbbm getSbbm() {
        return sbbm;
    }

    public void setSbbm(Nbbm sbbm) {
        this.sbbm = sbbm;
    }

    public Yg getSbr() {
        return sbr;
    }

    public void setSbr(Yg sbr) {
        this.sbr = sbr;
    }

    public Boolean getZbcg() {
        return zbcg;
    }

    public void setZbcg(Boolean zbcg) {
        this.zbcg = zbcg;
    }

    public Gsjg getWlfgs() {
        return wlfgs;
    }

    public void setWlfgs(Gsjg wlfgs) {
        this.wlfgs = wlfgs;
    }

    public Nbbm getWlfbm() {
        return wlfbm;
    }

    public void setWlfbm(Nbbm wlfbm) {
        this.wlfbm = wlfbm;
    }

    public Yg getWlfry() {
        return wlfry;
    }

    public void setWlfry(Yg wlfry) {
        this.wlfry = wlfry;
    }

    public Date getJsrq() {
        return jsrq;
    }

    public void setJsrq(Date jsrq) {
        this.jsrq = jsrq;
    }

    public Sjzdz getHtxz() {
        return htxz;
    }

    public void setHtxz(Sjzdz htxz) {
        this.htxz = htxz;
    }

    public String getBz() {
        return bz;
    }

    public void setBz(String bz) {
        this.bz = bz;
    }

    public Yg getZdr() {
        return zdr;
    }

    public void setZdr(Yg zdr) {
        this.zdr = zdr;
    }

    public Date getZdsj() {
        return zdsj;
    }

    public void setZdsj(Date zdsj) {
        this.zdsj = zdsj;
    }

    public String getZt() {
        return zt;
    }

    public void setZt(String zt) {
        this.zt = zt;
    }

    public String getHtbm() {
        return htbm;
    }

    public void setHtbm(String htbm) {
        this.htbm = htbm;
    }

    public Htwb getHtwb() {
        return htwb;
    }

    public void setHtwb(Htwb htwb) {
        this.htwb = htwb;
    }

    public List<Fj> getFjList() {
        return fjList;
    }

    public void setFjList(List<Fj> fjList) {
        this.fjList = fjList;
    }

    public List<Htmx> getHtmxList() {
        return htmxList;
    }

    public void setHtmxList(List<Htmx> htmxList) {
        this.htmxList = htmxList;
    }

    public String getProcessInstanceId() {
        return processInstanceId;
    }

    public void setProcessInstanceId(String processInstanceId) {
        this.processInstanceId = processInstanceId;
    }

    public String getHtqdr() {
        return htqdr;
    }

    public void setHtqdr(String htqdr) {
        this.htqdr = htqdr;
    }

    public Boolean getSfdrbght() {
        return sfdrbght;
    }

    public void setSfdrbght(Boolean sfdrbght) {
        this.sfdrbght = sfdrbght;
    }

    public List<Fkfs> getHtfkfs() {
        return htfkfs;
    }

    public void setHtfkfs(List<Fkfs> htfkfs) {
        this.htfkfs = htfkfs;
    }

    public String getHtms() {
        return htms;
    }

    public void setHtms(String htms) {
        this.htms = htms;
    }
}
